using System;
using System.Collections;
using System.Collections.Generic;
using Framework.Library.Core.Config;
using Framework.Library.Core.Data.DataEngine;
using Framework.Library.Data.DAL;
using Framework.Library.Data.IDAO;
using Framework.Library.Core.Utils.Database;
using System.Data;

namespace Framework.Library.Data.DAO.SqlServer
{
    [Serializable]
    internal class TeenioPermissionManager : ITeenioPermissionManager
    {
        public int CheckUserPermision(int userId, int portalid)
        {
            QueryBuilder builder = new QueryBuilder("TEENIO_USERPERMISIONS");
            builder.AddCondition("USERID", userId);
            builder.AddCondition("PORTALID", portalid);
            builder.AddColumn("PERMISION");
            return Convert.ToInt32(GeneralConnection.ExecuteScalar(CommandType.Text, builder));
        }

        public TeenioPermission GetPermision(int userId, int portalid)
        {
            QueryBuilder builder = new QueryBuilder("TEENIO_USERPERMISIONS");
            builder.AddCondition("USERID", userId);
            builder.AddCondition("PORTALID", portalid);
            List<TeenioPermission> tab = GeneralConnection.ExecuteList<TeenioPermission>(CommandType.Text, builder);
            if (tab.Count > 0)
                return tab[0];
            return null;
        }
    }
}